<template>
  <!-- vue3页面 -->
  <a-card>
    <a-row>
      <a-col :span="4">
        <a-input
          v-model:value="params.conferenceName"
          placeholder="请输入会议名称"
        ></a-input>
      </a-col>
      <a-col :span="4">
        <MySelect
          title="请选择工会"
          v-model:value="params.union"
          :style="{ width: '100%', paddingLeft: '10px' }"
          :select-data="unions"
          :field-names="{ label: 'unionname', value: 'id' }"
        ></MySelect>
      </a-col>
      <a-col :span="4">
        <MySelect
          title="请选择单位"
          v-model:value="params.union"
          :style="{ width: '100%', paddingLeft: '10px' }"
          :select-data="[]"
          :field-names="{ label: 'unionname', value: 'id' }"
        ></MySelect>
      </a-col>
      <a-col :span="4">
        <a-button style="margin-left: 10px" type="primary"> 搜索 </a-button>
      </a-col>
      <a-col :span="4"></a-col>
      <a-col :span="4"></a-col>
    </a-row>
  </a-card>
  <MyTable
    :table-data="dataSource"
    row-key="id"
    useNumber
    :columns="columns"
  ></MyTable>
</template>

<script setup lang="ts">
import { ref, onMounted, h } from "vue";
import MyTable from "@/components/CommonDai/Table.vue";
import MySelect from "@/components/CommonDai/SelectSearch.vue";
import { getCegnorssApprovalAll, SecondLevelCongress } from "./api";
import { Tag } from "ant-design-vue";

onMounted(async () => {
  const res = (await getCegnorssApprovalAll()) as SecondLevelCongress;
  dataSource.value = res.list as SecondLevelCongress["list"][];
});
const params = ref({
  conferenceName: "",
  union: null,
  approvalStatus: undefined,
});

const unions = [
  {
    id: "42732374678f420b8fea9c044accb6ea",
    unionname: "机关分工会",
    unioncode: "01",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "ef6f7fe75ab148bc8e99bdb01e5efbbd",
    unionname: "商学院分工会",
    unioncode: "02",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "da270aa8557a4918a309a499669069c7",
    unionname: "建筑工程学院分工会",
    unioncode: "03",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "5e1c05c1e8c94508a93bd01c5c844c0d",
    unionname: "信息工程学院分工会",
    unioncode: "04",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "9206f557b69743379bf37dbbf3147e23",
    unionname: "环境生态学院分工会",
    unioncode: "05",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "9ba577c3a119435c9a06c86b5116f771",
    unionname: "设计学院分工会",
    unioncode: "06",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "bbd81de5c6f647b7a51ef4a8b1ad3717",
    unionname: "艺术学院（健康学院）分工会",
    unioncode: "07",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "50bc251bd559430cb89353807f0c02a5",
    unionname: "教育学院分工会",
    unioncode: "08",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "abed52a2495843348ea383fa7c74332a",
    unionname: "外国语学院分工会",
    unioncode: "09",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "69128bae981f40a68c02eecffec2f107",
    unionname: "公共管理学院分工会",
    unioncode: "10",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "5642bee1f0df48a1a6cebaf69ed3aad4",
    unionname: "马克思主义学院分工会",
    unioncode: "11",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "a80eebf7074948bcbce18daa1fcb42b9",
    unionname: "国开分部教学管理中心分工会",
    unioncode: "12",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
  {
    id: "b9f8f8dee6f7477cad60a3f14a4d2a2d",
    unionname: "乡村振兴学院分工会",
    unioncode: "13",
    unionaddress: null,
    uniontime: null,
    unionleader: null,
    telephone: null,
    campus: "鼓楼校区",
    isEnable: false,
  },
];
const dataSource = ref<SecondLevelCongress["list"][]>([]);
const columns = ref([
  {
    title: "会议名称",
    dataIndex: "conferenceName",
    key: "conferenceName",
    isShow: true,
    align: "center",
  },
  {
    title: "会议时间",
    dataIndex: "conferenceTime",
    key: "conferenceTime",
    isShow: true,
    align: "center",
  },
  {
    title: "届次",
    dataIndex: "session",
    key: "session",
    isShow: true,
    align: "center",
  },
  {
    title: "申请人",
    dataIndex: "applyUser",
    key: "applyUser",
    isShow: true,
    align: "center",
  },
  {
    title: "所在单位",
    dataIndex: "inDepartment",
    key: "inDepartment",
    isShow: true,
    align: "center",
  },
  {
    title: "所在工会",
    dataIndex: "inUnion",
    key: "inUnion",
    isShow: true,
    align: "center",
  },
  {
    title: "会议类型",
    dataIndex: "conferenceType",
    key: "conferenceType",
    isShow: true,
    align: "center",
  },
  {
    title: "申请时间",
    dataIndex: "applyTime",
    key: "applyTime",
    isShow: true,
    align: "center",
  },
  {
    title: "审核状态",
    dataIndex: "auditState",
    key: "auditState",
    isShow: true,
    align: "center",
    customRender: ({ text }: any) => {
      return text === 0
        ? h(Tag, { color: "green" }, "未审核")
        : h(Tag, { color: "blue" }, "已审核");
    },
  },
  {
    title: "操作",
    dataIndex: "action",
    key: "action",
    isShow: true,
    align: "center",
    customRender: () => {
      return h("span", {}, [
        h("a", null, "查看"),
        h("a", { style: { marginLeft: "10px", color: "#ff4d4f" } }, "删除"),
      ]);
    },
  },
]);
</script>

<style scoped lang="less">
:deep(svg) {
  vertical-align: middle;
}
</style>
